
Ext.require('Ext.window.MessageBox');
//创建Grid表格组件
Ext.define('A5T.view.mywin.DeploymentGrid',{
    extend: 'Ext.grid.Panel',
    id:"deploymentGrid",
    width:1200,
    height:1000,
    layout: 'fit',
    frame:true,
    forceFit:true,
    viewConfig: {
        forceFit : true,
        stripeRows: true//在表格中显示斑马线
    },
    columns: [//配置表格列
            {header: "id", width: 30, dataIndex: 'id', sortable: true},
            {header: "名称", width: 80, dataIndex: 'name', sortable: true},
            {header: "分类", width: 80, dataIndex: 'category', sortable: true},
            {header: "部署时间", width: 80, dataIndex: 'deploymentTime', sortable: true},
            {  
               text:'操作',  
               menuDisabled: true,  
               sortable: false,  
               align:'center',  
               xtype: 'actioncolumn',  
               width: 60,  
               items: [{  
                   icon   :'/a5t/icons/play.gif',  
                   id: 'play',  
                   tooltip: '启动一个流程实例',  
                   handler: function(grid, rowIndex, colIndex) {   //rowIndex，colIndex均从0开始  
                	   Ext.Ajax.request( {  
                           url : '/a5t/act/initiate.json',  
                           method : 'get',  
                           params : {},  
                           success : function(response, options) { 
                               var res = Ext.decode(response.responseText);
                               if(res.success){
                            	   Ext.Msg.alert('', '部署成功');
                               }else
                               {
                                   Ext.Msg.alert('', '部署失败');
                               }                                        

                           },  
                           failure : function() {
                               Ext.Msg.alert('', '部署失败');
                           }  
                       });
                   }  
            }]  
    }],
    initComponent: function ()
    {
        var me = this;
        var store = Ext.create('A5T.store.Deployments');
        me.store = store;
        me.callParent(arguments);
    },
    dockedItems:[  
        //添加搜索控件  
        {  
             dock: 'top',   
             xtype: 'toolbar',   
             items: [{
                    xtype: 'button',
                    handler: function(button, e) {

                        
                        
                        Ext.Ajax.request( {  
                                    url : '/a5t/act/deployment.json',  
                                    method : 'get',  
                                    params : {},  
                                    success : function(response, options) { 
                                        var res = Ext.decode(response.responseText);
                                        if(res.success){
                                            var store = Ext.data.StoreManager.lookup('deploymentsStore');
                                            store.reload();

                                        }else
                                        {
                                            Ext.Msg.alert('', '部署失败');
                                        }                                        

                                    },  
                                    failure : function() {
                                        Ext.Msg.alert('', '部署失败');
                                    }  
                                });
                    },
                    itemId: 'deploymentBtn',
                    text: '部署流程'
                },

                {
                    xtype: 'button',
                    handler: function(button, e) {
                        
                        Ext.Ajax.request( {  
                                    url : '/a5t/act/clearAll.json',  
                                    method : 'get',  
                                    params : {},  
                                    success : function(response, options) { 
                                        var res = Ext.decode(response.responseText);
                                        if(res.success){
                                            var store = Ext.data.StoreManager.lookup('deploymentsStore');
                                            store.reload();

                                        }else
                                        {
                                            Ext.Msg.alert('', '部署失败');
                                        }                                        

                                    },  
                                    failure : function() {
                                        Ext.Msg.alert('', '部署失败');
                                    }  
                                });
                    },
                    itemId: 'clearAllBtn',
                    text: '清除'
                }]
        },{   
             dock: 'bottom',   
             xtype: 'pagingtoolbar',   
             store: Ext.data.StoreManager.lookup('deploymentsStore'),   
             displayInfo: true,   
             displayMsg: '显示 {0} - {1} 条，共计 {2} 条',   
             emptyMsg: '没有数据'   
        }]
});